//
//  BaseTableViewController.swift
//  Weibo
//
//  Created by 付启刚 on 15/12/13.
//  Copyright © 2015年 faq. All rights reserved.
//

import UIKit
//根据用户是否登录 去显示访客视图 还是表视图
class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
var userLogin=UserAccountViewModel().userLogin
    var visitorLoginView : VisitorLoginView?
    override func loadView() {
        if userLogin{
            //显示tableView
           super.loadView()
        }else{
        setVisitorLoginView()
        }
    }
    private func setVisitorLoginView(){
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.vistorLoginViewDelegate=self
        view=visitorLoginView
        self.navigationItem.rightBarButtonItem=UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        self.navigationItem.leftBarButtonItem=UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    func userWillLogin(){
        //初始化定义一个oauth控制器实例
        let oauth=OAuthViewController()
//        将oauth控制器添加到导航控制器
        let nav=UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    print(__FUNCTION__)
    }
    func userWillRegister(){
    print(__FUNCTION__)
    }
}
